# token值封装

import requests

from data.common.authorization import TokenData


def authorization_code():
	"""
	读取login接口，获取authorization值，用于接口token校验。
	:return:authorization值
	"""
	response = requests.post(url=TokenData.url, headers=TokenData.headers, json=TokenData.json)
	res_loads = response.json()  # 直接使用 response.json() 解析 JSON
	if res_loads.get('code') == 200:  # 检查响应状态码
		res_token = res_loads.get('token')
		return res_token
	else:
		print(f"Failed to authenticate: {res_loads}")
		return None


if __name__ == '__main__':
	authorization_code()
